const vscode = require("vscode");
const Util = require("./util");
const AjjlDatas = require("./ajjlDatas");


/**
 * 获取按键精灵函数库信息
 * @param {any} document
 * @return {Array} [{class, postfix, path, content, infos: [{name, type, params: [param1, param2...]}]}]
 */
function getAjjlFunctionLibrary(document) {
    let projectPath = "";

    // 判断文件类型
    let isQFile = /\\.*\.Q$/.test(document.fileName);
    if (isQFile) { projectPath = Util.getProjectPath(document); }

    // 获取函数库数据
    let configurationGrogramPath = vscode.workspace.getConfiguration().get("Ajjl.Grogram.Path");
    let ajjlFunctionFilesInfoList = AjjlDatas.getAjjlFilesInfoList(configurationGrogramPath + "\\lib", ".qml", true);
    return AjjlDatas.getAjjlFilesInfoList(projectPath, ".Q", true).concat(ajjlFunctionFilesInfoList);
}

/**
 * @param {any} context
 */
module.exports = { getAjjlFunctionLibrary };